/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tces.controller;

import com.tces.model.SubjectOffering;
import com.tces.model.SubjectSchedule;
import com.tces.utils.ConnectionDAO;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author arnolda
 */
public class SubjectScheduleDAO extends ConnectionDAO {

    private static final Logger log = Logger.getLogger(SubjectScheduleDAO.class);

    public static List<SubjectSchedule> find() throws Exception {
        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        String sql = "SELECT\n"
                + "	i.instructor_id,\n"
                + "	concat_ws(\n"
                + "		' ',\n"
                + "		concat_ws(\n"
                + "			', ',\n"
                + "			i.instructor_last_name,\n"
                + "			i.instructor_first_name\n"
                + "		),\n"
                + "		i.instructor_middle_name\n"
                + "	) instructor_fullname,\n"
                + "	ss.subject_schedule_id,\n"
                + "	ss.subject_schedule,\n"
                + "	ss.schedule_status,\n"
                + "	s.subject_id,\n"
                + "	s.subject_name,\n"
                + "	s.subject_description,\n"
                + "	s.subject_status,\n"
                + "	s.subject_lec_units,\n"
                + "	s.subject_lab_units,\n"
                + "	s.subject_type,\n"
                + "	so.subject_offering_id,\n"
                + "	so.subject_offering_name,\n"
                + "	c.college_id,\n"
                + "	c.college_code,\n"
                + "	c.college_name,\n"
                + "	ss.subject_code\n"
                + "FROM\n"
                + "	subject_schedules AS ss\n"
                + "INNER JOIN subject_offerings AS so ON so.subject_offering_id = ss.subject_offering_id\n"
                + "INNER JOIN subjects AS s ON s.subject_id = ss.subject_id\n"
                + "INNER JOIN instructors AS i ON i.instructor_id = ss.instructor_id\n"
                + "INNER JOIN colleges AS c ON c.college_id = so.college_id";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();
        SubjectSchedule subjectSchedule;
        while (rs.next()) {
            subjectSchedule = new SubjectSchedule();
            subjectSchedule.setSubjectOfferingID(rs.getInt("subject_offering_id"));
            subjectSchedule.setSubjectScheduleID(rs.getInt("subject_schedule_id"));
            subjectSchedule.setScheduleStatus(rs.getInt("schedule_status"));
            subjectSchedule.setSubjectID(rs.getInt("subject_id"));
            subjectSchedule.setSubjectType(rs.getInt("subject_type"));
            subjectSchedule.setSubjectStatus(rs.getInt("subject_status"));
            subjectSchedule.setInstructorID(rs.getInt("instructor_id"));
            subjectSchedule.setSubjectLecUnits(rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectLabUnits(rs.getDouble("subject_lab_units"));
            subjectSchedule.setTotalUnits(rs.getDouble("subject_lab_units") + rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectOfferingName(rs.getString("subject_offering_name"));
            subjectSchedule.setSubjectOfferingFullName(rs.getString("college_code") + " - " + rs.getString("subject_offering_name"));
            subjectSchedule.setInstructorFullName(rs.getString("instructor_fullname"));
            subjectSchedule.setSubjectSchedule(rs.getString("subject_schedule"));
            subjectSchedule.setSubjectCode(rs.getString("subject_code"));
            subjectSchedule.setSubjectDescription(rs.getString("subject_description"));
//            subjectSchedule.setInstructorFirstName(rs.getString("instructor_first_name"));
//            subjectSchedule.setInstructorMiddleName(rs.getString("instructor_middle_name"));
//            subjectSchedule.setInstructorLastName(rs.getString("instructor_last_name"));
            subjectList.add(subjectSchedule);
        }
        closeConnection(getConnectionObject());
        return subjectList;
    }

    public static List<SubjectSchedule> find(int collegeID) throws Exception {
        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        String sql = "SELECT\n"
                + "	i.instructor_id,\n"
                + "	concat_ws(\n"
                + "		' ',\n"
                + "		concat_ws(\n"
                + "			', ',\n"
                + "			i.instructor_last_name,\n"
                + "			i.instructor_first_name\n"
                + "		),\n"
                + "		i.instructor_middle_name\n"
                + "	) instructor_fullname,\n"
                + "	ss.subject_schedule_id,\n"
                + "	ss.subject_schedule,\n"
                + "	ss.schedule_status,\n"
                + "	s.subject_id,\n"
                + "	s.subject_name,\n"
                + "	s.subject_description,\n"
                + "	s.subject_status,\n"
                + "	s.subject_lec_units,\n"
                + "	s.subject_lab_units,\n"
                + "	s.subject_type,\n"
                + "	so.subject_offering_id,\n"
                + "	so.subject_offering_name,\n"
                + "	c.college_id,\n"
                + "	c.college_code,\n"
                + "	c.college_name,\n"
                + "	ss.subject_code\n"
                + "FROM\n"
                + "	subject_schedules AS ss\n"
                + "INNER JOIN subject_offerings AS so ON so.subject_offering_id = ss.subject_offering_id\n"
                + "INNER JOIN subjects AS s ON s.subject_id = ss.subject_id\n"
                + "INNER JOIN instructors AS i ON i.instructor_id = ss.instructor_id\n"
                + "INNER JOIN colleges AS c ON c.college_id = so.college_id\n"
                + "WHERE\n"
                + "	so.subject_offering_status = 1\n"
                + "AND c.college_id = ?";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        preparedStatement.setInt(1, collegeID);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();
        SubjectSchedule subjectSchedule;
        while (rs.next()) {
            subjectSchedule = new SubjectSchedule();
            subjectSchedule.setSubjectOfferingID(rs.getInt("subject_offering_id"));
            subjectSchedule.setSubjectScheduleID(rs.getInt("subject_schedule_id"));
            subjectSchedule.setScheduleStatus(rs.getInt("schedule_status"));
            subjectSchedule.setSubjectID(rs.getInt("subject_id"));
            subjectSchedule.setSubjectType(rs.getInt("subject_type"));
            subjectSchedule.setSubjectStatus(rs.getInt("subject_status"));
            subjectSchedule.setInstructorID(rs.getInt("instructor_id"));
            subjectSchedule.setSubjectLecUnits(rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectLabUnits(rs.getDouble("subject_lab_units"));
            subjectSchedule.setTotalUnits(rs.getDouble("subject_lab_units") + rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectOfferingName(rs.getString("subject_offering_name"));
            subjectSchedule.setSubjectOfferingFullName(rs.getString("subject_code") + " - " + rs.getString("subject_offering_name"));
            subjectSchedule.setInstructorFullName(rs.getString("instructor_fullname"));
            subjectSchedule.setSubjectSchedule(rs.getString("subject_schedule"));
            subjectSchedule.setSubjectCode(rs.getString("subject_code"));
            subjectSchedule.setSubjectDescription(rs.getString("subject_description"));
//            subjectSchedule.setInstructorFirstName(rs.getString("instructor_first_name"));
//            subjectSchedule.setInstructorMiddleName(rs.getString("instructor_middle_name"));
//            subjectSchedule.setInstructorLastName(rs.getString("instructor_last_name"));
            subjectList.add(subjectSchedule);
        }
        closeConnection(getConnectionObject());
        return subjectList;
    }
   /**
    * This method is used in creating the subject option in Subject Class List
    * @return
    * @throws Exception 
    */
    public static List<SubjectSchedule> getSubjectScheduleOption() throws Exception {
        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        String sql = "SELECT\n"
                + "	i.instructor_id,\n"
                + "	concat_ws(\n"
                + "		' ',\n"
                + "		concat_ws(\n"
                + "			', ',\n"
                + "			i.instructor_last_name,\n"
                + "			i.instructor_first_name\n"
                + "		),\n"
                + "		i.instructor_middle_name\n"
                + "	) instructor_fullname,\n"
                + "	ss.subject_schedule_id,\n"
                + "	ss.subject_schedule,\n"
                + "	ss.schedule_status,\n"
                + "	s.subject_id,\n"
                + "	s.subject_name,\n"
                + "	s.subject_description,\n"
                + "	s.subject_status,\n"
                + "	s.subject_lec_units,\n"
                + "	s.subject_lab_units,\n"
                + "	s.subject_type,\n"
                + "	so.subject_offering_id,\n"
                + "	so.subject_offering_name,\n"
                + "	c.college_id,\n"
                + "	c.college_code,\n"
                + "	c.college_name,\n"
                + "	ss.subject_code\n"
                + "FROM\n"
                + "	subject_schedules AS ss\n"
                + "INNER JOIN subject_offerings AS so ON so.subject_offering_id = ss.subject_offering_id\n"
                + "INNER JOIN subjects AS s ON s.subject_id = ss.subject_id\n"
                + "INNER JOIN instructors AS i ON i.instructor_id = ss.instructor_id\n"
                + "INNER JOIN colleges AS c ON c.college_id = so.college_id\n"
                + "WHERE\n"
                + "	so.subject_offering_status = 1 AND s.subject_status=1\n";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();
        SubjectSchedule subjectSchedule;
        while (rs.next()) {
            subjectSchedule = new SubjectSchedule();
            subjectSchedule.setSubjectOfferingID(rs.getInt("subject_offering_id"));
            subjectSchedule.setSubjectScheduleID(rs.getInt("subject_schedule_id"));
            subjectSchedule.setScheduleStatus(rs.getInt("schedule_status"));
            subjectSchedule.setSubjectID(rs.getInt("subject_id"));
            subjectSchedule.setSubjectType(rs.getInt("subject_type"));
            subjectSchedule.setSubjectStatus(rs.getInt("subject_status"));
            subjectSchedule.setInstructorID(rs.getInt("instructor_id"));
            subjectSchedule.setSubjectLecUnits(rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectLabUnits(rs.getDouble("subject_lab_units"));
            subjectSchedule.setTotalUnits(rs.getDouble("subject_lab_units") + rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectOfferingName(rs.getString("subject_offering_name"));
            subjectSchedule.setSubjectOfferingFullName(rs.getString("college_code") + " - " +rs.getString("subject_offering_name") + " - " + rs.getString("subject_code") +" : "+rs.getString("instructor_fullname"));
            subjectSchedule.setInstructorFullName(rs.getString("instructor_fullname"));
            subjectSchedule.setSubjectSchedule(rs.getString("subject_schedule"));
            subjectSchedule.setSubjectCode(rs.getString("subject_code"));
            subjectSchedule.setSubjectDescription(rs.getString("subject_description"));
//            subjectSchedule.setInstructorFirstName(rs.getString("instructor_first_name"));
//            subjectSchedule.setInstructorMiddleName(rs.getString("instructor_middle_name"));
//            subjectSchedule.setInstructorLastName(rs.getString("instructor_last_name"));
            subjectList.add(subjectSchedule);
        }
        closeConnection(getConnectionObject());
        return subjectList;
    }

    public static SubjectSchedule getSchedule(int subjectScheduleID) throws Exception {
//        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        SubjectSchedule subjectSchedule = null;
        String sql = "SELECT\n"
                + "	i.instructor_id,\n"
                + "	concat_ws(\n"
                + "		' ',\n"
                + "		concat_ws(\n"
                + "			', ',\n"
                + "			i.instructor_last_name,\n"
                + "			i.instructor_first_name\n"
                + "		),\n"
                + "		i.instructor_middle_name\n"
                + "	) instructor_fullname,\n"
                + "	ss.subject_schedule_id,\n"
                + "	ss.subject_schedule,\n"
                + "	ss.schedule_status,\n"
                + "	s.subject_id,\n"
                + "	s.subject_name,\n"
                + "	s.subject_description,\n"
                + "	s.subject_status,\n"
                + "	s.subject_lec_units,\n"
                + "	s.subject_lab_units,\n"
                + "	s.subject_type,\n"
                + "	so.subject_offering_id,\n"
                + "	so.subject_offering_name,\n"
                + "	c.college_id,\n"
                + "	c.college_code,\n"
                + "	c.college_name,\n"
                + "	ss.subject_code\n"
                + "FROM\n"
                + "	subject_schedules AS ss\n"
                + "INNER JOIN subject_offerings AS so ON so.subject_offering_id = ss.subject_offering_id\n"
                + "INNER JOIN subjects AS s ON s.subject_id = ss.subject_id\n"
                + "INNER JOIN instructors AS i ON i.instructor_id = ss.instructor_id\n"
                + "INNER JOIN colleges AS c ON c.college_id = so.college_id\n"
                + "WHERE\n"
                + "	so.subject_offering_status = 1\n"
                + "AND ss.subject_schedule_id = ?";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        preparedStatement.setInt(1, subjectScheduleID);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();

        while (rs.next()) {
            subjectSchedule = new SubjectSchedule();
            subjectSchedule.setSubjectOfferingID(rs.getInt("subject_offering_id"));
            subjectSchedule.setSubjectScheduleID(rs.getInt("subject_schedule_id"));
            subjectSchedule.setScheduleStatus(rs.getInt("schedule_status"));
            subjectSchedule.setSubjectID(rs.getInt("subject_id"));
            subjectSchedule.setSubjectType(rs.getInt("subject_type"));
            subjectSchedule.setSubjectStatus(rs.getInt("subject_status"));
            subjectSchedule.setInstructorID(rs.getInt("instructor_id"));
            subjectSchedule.setSubjectLecUnits(rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectLabUnits(rs.getDouble("subject_lab_units"));
            subjectSchedule.setTotalUnits(rs.getDouble("subject_lab_units") + rs.getDouble("subject_lec_units"));
            subjectSchedule.setSubjectOfferingName(rs.getString("subject_offering_name"));
            subjectSchedule.setSubjectOfferingFullName(rs.getString("subject_code") + " - " + rs.getString("subject_offering_name"));
            subjectSchedule.setInstructorFullName(rs.getString("instructor_fullname"));
            subjectSchedule.setSubjectSchedule(rs.getString("subject_schedule"));
            subjectSchedule.setSubjectCode(rs.getString("subject_code"));
            subjectSchedule.setSubjectDescription(rs.getString("subject_description"));
//            subjectSchedule.setInstructorFirstName(rs.getString("instructor_first_name"));
//            subjectSchedule.setInstructorMiddleName(rs.getString("instructor_middle_name"));
//            subjectSchedule.setInstructorLastName(rs.getString("instructor_last_name"));
//            subjectList.add(subjectSchedule);
        }
        closeConnection(getConnectionObject());
        return subjectSchedule;
    }
    public static List<String> getScheduleEvaluationSuggestion(int subjectScheduleID) throws Exception {
       
        List<String> suggestionList = new ArrayList<String>();
        try{
        String sql = "SELECT * FROM subject_evaluation_suggestions WHERE subject_schedule_id=?";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        preparedStatement.setInt(1, subjectScheduleID);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();
        log.info(rs.wasNull());
        while (rs.next()) {
            suggestionList.add(rs.getString("subject_evaluation_suggestion"));
        }
        log.info("Suggestion SIZE: "+suggestionList.size());
        closeConnection(getConnectionObject());
        }catch(Exception ex){
        
        }
        
        
        return suggestionList;
    }

    public static SubjectSchedule getEvaluatedSchedule(int subjectScheduleID) throws Exception {
//        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        SubjectSchedule subjectSchedule = null;
        String sql = "SELECT\n"
                + "concat_ws(\n"
                + "		' ',\n"
                + "		concat_ws(\n"
                + "			', ',\n"
                + "			i.instructor_last_name,\n"
                + "			i.instructor_first_name\n"
                + "		),\n"
                + "		i.instructor_middle_name\n"
                + "	) instructor_fullname,\n"
                + "so.subject_offering_id,\n"
                + "so.subject_offering_name,\n"
                + "ss.subject_schedule_id,\n"
                + "ss.subject_code,\n"
                + "s.subject_description,\n"
                + "ss.subject_schedule,\n"
                + "Sum(dt.category_mean) AS total_mean,\n"
                + "IFNULL((SELECT rating_qualitative_interpretation FROM ratings WHERE rating_lower_limit <= sum(dt.category_mean) AND rating_upper_limit >= sum(dt.category_mean)  ),'Invalid Total Mean.') AS qualitative_interpretation\n"
                + "FROM\n"
                + "(\n"
                + "		SELECT\n"
                + "	tbl.subject_schedule_id,\n"
                + "	AVG(tbl.question_mean) * ct.category_percentage category_mean\n"
                + "FROM\n"
                + "	(\n"
                + "		SELECT\n"
                + "			ss.subject_schedule_id,\n"
                + "			se.question_id,\n"
                + "			SUM(c.choice_numeric_value) / (\n"
                + "				SELECT\n"
                + "					COUNT(\n"
                + "						DISTINCT subject_students.student_id\n"
                + "					)\n"
                + "				FROM\n"
                + "					subject_students\n"
                + "				WHERE\n"
                + "					subject_students.subject_schedule_id = se.subject_schedule_id\n"
                + "			) question_mean,\n"
                + "			cq.category_id\n"
                + "		FROM\n"
                + "			subject_evaluations AS se\n"
                + "		INNER JOIN choices AS c ON c.choice_id = se.choice_id\n"
                + "		INNER JOIN subject_schedules AS ss ON se.subject_schedule_id = ss.subject_schedule_id\n"
                + "		INNER JOIN categories_questions AS cq ON se.question_id = cq.question_id\n"
                + "		GROUP BY\n"
                + "			ss.subject_schedule_id,\n"
                + "			se.question_id\n"
                + "	) tbl\n"
                + "INNER JOIN categories ct ON tbl.category_id = ct.category_id\n"
                + "GROUP BY\n"
                + "	tbl.subject_schedule_id,\n"
                + "	ct.category_id\n"
                + "	) AS dt\n"
                + "INNER JOIN subject_schedules AS ss ON ss.subject_schedule_id = dt.subject_schedule_id\n"
                + "INNER JOIN instructors AS i ON ss.instructor_id = i.instructor_id\n"
                + "INNER JOIN subjects AS s ON s.subject_id = ss.subject_id\n"
                + "INNER JOIN subject_offerings AS so ON ss.subject_offering_id = so.subject_offering_id\n"
                + "WHERE ss.subject_schedule_id=?\n"
                + "GROUP BY\n"
                + "s.subject_id";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        preparedStatement.setInt(1, subjectScheduleID);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();

        while (rs.next()) {
            subjectSchedule = new SubjectSchedule();
            subjectSchedule.setInstructorFullName(rs.getString("instructor_fullname"));
            subjectSchedule.setSubjectOfferingID(rs.getInt("subject_offering_id"));
            subjectSchedule.setSubjectScheduleID(rs.getInt("subject_schedule_id"));
            subjectSchedule.setTotalMean(rs.getDouble("total_mean"));
            subjectSchedule.setSubjectOfferingName(rs.getString("subject_offering_name"));
            subjectSchedule.setSubjectSchedule(rs.getString("subject_schedule"));
            subjectSchedule.setSubjectCode(rs.getString("subject_code"));
            subjectSchedule.setSubjectDescription(rs.getString("subject_description"));
            subjectSchedule.setQualitativeInterpretation(rs.getString("qualitative_interpretation"));
        }
        closeConnection(getConnectionObject());
        return subjectSchedule;
    }

    public static int getStudentCount(int subjectScheduleID) throws Exception {
//        List<SubjectSchedule> subjectList = new ArrayList<SubjectSchedule>();
        int result = 0;
        String sql = "SELECT COUNT(1) student_count FROM subject_students WHERE subject_schedule_id = ?";

        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        preparedStatement.setInt(1, subjectScheduleID);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();

        while (rs.next()) {
            result = rs.getInt("student_count");
        }
        closeConnection(getConnectionObject());
        return result;
    }

    public static int add(SubjectSchedule schedule) throws Exception {
        try {
//            int result = 0;
            String sql = "INSERT INTO subject_schedules(subject_offering_id, instructor_id,subject_id,subject_schedule,schedule_status, subject_code,user_id) VALUES (?, ?,?,?,?,?,?)";
            PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
            preparedStatement.setInt(1, schedule.getSubjectOfferingID());
            preparedStatement.setInt(2, schedule.getInstructorID());
            preparedStatement.setInt(3, schedule.getSubjectID());
            preparedStatement.setString(4, schedule.getSubjectSchedule());
            preparedStatement.setInt(5, schedule.getScheduleStatus());
            preparedStatement.setString(6, schedule.getSubjectCode());
            preparedStatement.setInt(7, schedule.getUserID());
            log.info(preparedStatement.toString());
//            if (preparedStatement.executeUpdate() > 0) {
//                result = setUserCredential(schedule);
//                if (result <= 0) {
//                    throw (new Exception("Unable to create login credential for the instructor."));
//                }
//            } else {
//                throw (new Exception("Unable insert the instructor."));
//            }
            return preparedStatement.executeUpdate();
        } catch (Exception ex) {
            log.error(ex);
            throw ex;
        }
    }

    public static int update(SubjectSchedule schedule) throws Exception {
        try {
//            int result = 0;
            String sql = "UPDATE subject_schedules SET subject_offering_id=?, instructor_id=?,subject_id=?,subject_schedule=?,schedule_status=?, subject_code=?,user_id=? WHERE subject_schedule_id=?";
            PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
            preparedStatement.setInt(1, schedule.getSubjectOfferingID());
            preparedStatement.setInt(2, schedule.getInstructorID());
            preparedStatement.setInt(3, schedule.getSubjectID());
            preparedStatement.setString(4, schedule.getSubjectSchedule());
            preparedStatement.setInt(5, schedule.getScheduleStatus());
            preparedStatement.setString(6, schedule.getSubjectCode());
            preparedStatement.setInt(7, schedule.getUserID());
            preparedStatement.setInt(8, schedule.getSubjectScheduleID());
            log.info(preparedStatement.toString());
//            if (preparedStatement.executeUpdate() > 0) {
//                result = updateUserCredential(schedule);
//                if (result <= 0) {
//                    throw (new Exception("Unable to update login credential for the instructor."));
//                }
//            } else {
//                throw (new Exception("Unable update the instructor."));
//            }
            return preparedStatement.executeUpdate();
        } catch (Exception ex) {
            log.error(ex);
            throw ex;
        }
    }
    public static int delete(int subjectScheduleID) throws Exception {
        try {
            String sql = "DELETE FROM subject_schedules WHERE subject_schedule_id=?";
            PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
            preparedStatement.setInt(1, subjectScheduleID);
            log.info(preparedStatement.toString());
            return preparedStatement.executeUpdate();
        } catch (Exception ex) {
            log.error(ex);
            throw ex;
        }
    }
}
